package com.zhousb.deviceManager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhousb.deviceManager.mapper.InventoryMapper;
import com.zhousb.deviceManager.model.bo.CreateAssetByInventoryBO;
import com.zhousb.deviceManager.model.entity.KtInventory;
import com.zhousb.deviceManager.model.enums.OrderStatusEnum;
import com.zhousb.deviceManager.model.so.OrderSO;
import com.zhousb.deviceManager.service.InventoryService;
import io.netty.util.internal.StringUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class InventoryServiceImpl implements InventoryService {

    @Resource
    private InventoryMapper inventoryMapper;

    @Override
    public Page<KtInventory> page(Page<KtInventory> page, OrderSO so) {
        LambdaQueryWrapper<KtInventory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(!so.getOrderStatus().equals(OrderStatusEnum.DEFAULT.getCode()), KtInventory::getOrderStatus, so.getOrderStatus())
                .eq(StringUtils.hasText(so.getClientName()), KtInventory::getClientName, so.getClientName())
                .eq(StringUtils.hasText(so.getOrderCode()), KtInventory::getOrderCode, so.getOrderCode());
        return inventoryMapper.selectPage(page, queryWrapper);
    }


}
